package net.csdn.business.common.feign.interceptor;

import io.opentracing.propagation.TextMap;
import okhttp3.Headers;
import okhttp3.Request;
import org.springframework.http.HttpHeaders;

import java.util.Iterator;
import java.util.Map;

public class HttpHeadersCarrier implements TextMap {
    private Request.Builder requestBuilder;

    public HttpHeadersCarrier(Request.Builder requestBuilder)  {
        this.requestBuilder = requestBuilder;
    }

    @Override
    public void put(String key, String value) {
        requestBuilder.header(key, value);
    }

    @Override
    public Iterator<Map.Entry<String, String>> iterator() {
        throw new UnsupportedOperationException("Should be used only with tracer#inject()");
    }
}
